{extend name="main/index" /}
{block name="main"}
<!-- Start right content -->
<div class="content-page">
    <!-- ============================================================== -->
    <!-- Start Content here -->
    <!-- ============================================================== -->
    <div class="content">
        <!-- Page Heading Start -->
        <div class="page-heading">
            <h1><i class='fa fa-table'></i> 用户管理</h1>
            <h3>Basic & Simple Sortable Tables</h3></div>
        <!-- Page Heading End-->                <!-- Your awesome content goes here -->
        
        <div class="row">
            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>{$title}</strong> CRUD Table</h2>
                        <div class="additional-btn">
                            <a href="#" class="hidden reload"><i class="icon-ccw-1"></i></a>
                            <a href="#" class="widget-toggle"><i class="icon-down-open-2"></i></a>
                            <a href="#" class="widget-close"><i class="icon-cancel-3"></i></a>
                        </div>
                    </div>
                    <div class="widget-content">
                        <div class="data-table-toolbar">
                            <div class="row">
                                <div class="col-md-4">
                                    <!-- <form role="form">
                                        <input type="text" class="form-control" placeholder="Search...">
                                    </form> -->
                                </div>
                                <div class="col-md-8">
                                    <div class="toolbar-btn-action">
                                        <a class="btn btn-success" href="{:url('admin/User/add')}"><i class="fa fa-plus-circle" ></i>添加新用户</a>
                                        
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="table-responsive">
                            <table data-sortable class="table table-hover table-striped">
                                <thead>
                                <tr>
                                    <th>id</th>
                                    
                                    <th>用户名</th>
                                    <th>真实姓名</th>
                                    <th>所属角色</th>
                                    <th>状态</th>
                                    <th data-sortable="false">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                {volist name="ulist" key="k" id="v"}
                                <tr  class="oneNote{$v['id']}">
                                    <td>{$v['id']}</td>
                                    
                                    <td><strong>{$v['name']}</strong></td>
                                    <td>{$v['username']}</td>
                                    <td>{$v['rname']}</td>
                                    <td><span class="label label-success">Active</span></td>
                                    <td>
                                        <div class="btn-group btn-group-xs">
                                            
                                            <a onclick="delajax({$v['id']})" class="btn btn-danger del-btn del-res" title="Delete" ><i class="fa fa-trash-o"></i></a>
                                            
                                            <a data-toggle="tooltip" title="Role" class="btn btn-default" href="/rolelist/{$v['id']}/{$v['name']}"><i class="fa fa-edit"></i></a>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>

                        <div class="data-table-toolbar">
                            <!-- <ul class="pagination">
                                <li class="disabled"><a href="#">&laquo;</a></li>
                                <li class="active"><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li><a href="#">&raquo;</a></li>
                            </ul> -->
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <!-- Footer Start -->
        <footer>
            Huban Creative &copy; 2014
            <div class="footer-links pull-right">
                <a href="#">About</a><a href="#">Support</a><a href="#">Terms of Service</a><a href="#">Legal</a><a
                    href="#">Help</a><a href="#">Contact Us</a>
            </div>
        </footer>
        <!-- Footer End -->
    </div>
    <!-- ============================================================== -->
    <!-- End content here -->
    <!-- ============================================================== -->

</div>

{js href="/static/index/js/jquery-1.8.3.min.js"}
{js href="/static/layer/layer.js"}
<script>
    function delajax(id){
        layer.confirm('你确定要删除该用户?', {icon: 3, title:'提示'}, function(index){
            $.ajax({
                type : 'delete',
                dataType: 'json',
                url : '/delUser/'+ id,
                success : function(data)
                {
                    if(data == 200){
                        layer.msg('删除成功!!!', {icon: 1});
                        $('.oneNote'+ id).remove();
                    } else {
                        layer.msg('删除失败!!!');
                    }
                    layer.close(index);
                }
            });
        })
    }
</script>
<!-- <script>
   // ajax删除
    // 绑定点击事件
    $('.del-res').click(function(){
        var del_id = $(this).attr('del-id');
        var obj = $(this).parents('tr');

        $.ajax({
            type: 'delete',
            url: '/delUser/'+ del_id,
            dataType: 'json',
            success: function (data){
                if(data == 200){
                    obj.remove();

                }
            }

        })
    });



</script> -->
<!-- End right content -->
{js href="/static/admin/assets/js/jquery-1.8.3.min.js"}
{js href="/static/admin/assets/js/bootstrap.min.js"}
{js href="/static/admin/assets/js/toastr.min.js"}

{block name="myjs"}
<script>

    // 设置弹框参数
    toastr.options = {
        closeButton: true,// 是否显示关闭按钮
        progressBar: true,// 实现显示计时条
        timeOut: "3000",  // 自动关闭时间
        positionClass: "toast-top-right" // 提示位置
        // positionClass: "toast-top-full-width" // 提示位置
        // toast-top-full-width 顶端，宽度铺满整个屏幕
        // toast-top-right  顶端右边
    };


    // $(function () {
    //     // 触发 删除用户
    //     $('.del-btn').click(function () {
    //         var ac_id = $(this).attr('data-id');
    //         // console.log('删除的ID: ' + $(this).attr('data-id'));

    //         if (confirm('你确定要 [ 删除该用户 ] 吗?')) {
    //             var obj = $(this).parents('tr');
    //             console.log(obj);
    //             delAjax(ac_id, obj);
    //         }
    //     });
    // });

    // 执行AJAX查单用户信息
    // function showAjax(id) {
    //     $.ajax({
    //         type: 'get',
    //         url: '/users/' + id,
    //         dataType: 'json',
    //         success: function (data) {
    //             console.log(data);
    //             if (data.status) {
    //                 $('.modal-title u').html(data.title);
    //                 var msg = data.datas.id + ' | ' + data.datas.name + ' | ' + data.datas.age + ' | ' + data.datas.sex + ' | ' + data.datas.tel;
    //                     $('.modal-body h3').html(msg);
    //             } else {
    //                 $('.modal-title u').html(data.title);
    //                 $('.modal-body h3').html(data.datas);
    //             }
    //         },
    //         error: function () {
    //             alert('AJAX操作失败');
    //         }
    //     });
    // }
    // //"{:url('admin/User/delete','id='.$v['id'])}"
    // // 执行AJAX删除
    // function delAjax(id, obj) {
    //     $.ajax({
    //         type: 'delete',
    //         url:'/users/' + id,
    //         dataType: 'json',
    //         success: function (data) {
    //             console.log(data);
    //             if (data) {
    //                 toastr.success(data.info);
    //                 obj.remove();
    //             } else {
    //                 toastr.error(data.info, '该用户已经删除: ');
    //             }
    //         },
    //         error: function () {
    //             alert('AJAX操作失败');
    //         }
    //     });
    // }

</script>

{/block}


{/block}

